package com.ctg.payroll2.dao.social.impl;

import java.sql.SQLException;
import java.util.List;

import com.ctg.payroll2.bean.filter.social.CsSocialFilter;
import com.ctg.payroll2.bean.po.social.CsSocial;
import com.ctg.payroll2.bean.po.social.CsSocialDetail;
import com.ctg.payroll2.bean.po.social.CsTemplateSocialItemSearchBean;
import com.ctg.payroll2.dao.social.CustomTemplateDao;
import com.ctg.platform.orm.ibatis.IbatisEntityDao;
import com.ctg.platform.util.Page;

public class CustomTemplateDaoImpl extends IbatisEntityDao implements CustomTemplateDao{
	private String getNameSpace(){
		return getClass().getSimpleName();
	}

	public Page queryCustomTemplateByFilter(CsSocialFilter filter) {
		return pagedQueryByFilter(this.getClass(), filter,
				".queryCustomTemplate_count",
				".queryCustomTemplate_query");
	}
	
	public Long insertCsSocial(CsSocial csSocial){
		Long l = null;
		try {
			l = (Long)getSqlMapClient().insert(getNameSpace() + ".insertCsSocial",csSocial);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return l;
	}
	
	public void updateCsSocial(CsSocial csSocial){
		try {
			getSqlMapClient().update(getNameSpace() + ".updateCsSocial", csSocial);
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}
	
	@SuppressWarnings("unchecked")
	public List<CsSocial> getCsSocialByTemplateId(Long id){
		List<CsSocial> list = null;
		try {
			list = getSqlMapClient().queryForList(getNameSpace() + ".getCsSocialByTemplateId", id);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return list;
	}
	
	@SuppressWarnings("unchecked")
	public List<CsSocialDetail> getCsSocialDetailByTemplateId(Long id){
		List<CsSocialDetail> list = null;
		try {
			list = getSqlMapClient().queryForList(getNameSpace() + ".getCsSocialDetailByTemplateId", id);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return list;
	}
	

	public void deleteCsSocialDetailByIds(String detailIds) throws SQLException {
		getSqlMapClient().delete(getNameSpace() + ".deleteCsSocialDetailByIds", detailIds);
	}
	public void deleteCsSocialByIds(String ids) throws SQLException {
		getSqlMapClient().delete(getNameSpace() + ".deleteCsSocialDetailBySocialIds", ids);
		getSqlMapClient().delete(getNameSpace() + ".deleteCsSocialByIds", ids);
	}

	public void insertCsSocialDetail(CsTemplateSocialItemSearchBean detail) {
		try {
			getSqlMapClient().insert(getNameSpace()+".insertCsSocialDetail", detail);
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}

	public void updateCsSocialDetail(CsTemplateSocialItemSearchBean detail) {
		try {
			getSqlMapClient().update(getNameSpace()+".updateCsSocialDetail", detail);
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}
	
	public List getPbSocialItemByFilter(String templateId){
		List list = null;
		try {
			list = getSqlMapClient().queryForList(getNameSpace() + ".getPbSocialItemByFilter", templateId);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return list;
	}
}
